package tutorial.gae;

import javax.persistence.EntityManager;

import com.google.appengine.api.datastore.KeyFactory;

public class ContactJpaDao {

	public Contact get(long id) {
		EntityManager em = EMF.get().createEntityManager();
		Contact result = em.find(Contact.class,
				KeyFactory.createKey(ContactDao.ENTITY, id));
		em.close();
		return result;
	}

	public Contact create(Contact request) {
		EntityManager em = EMF.get().createEntityManager();
		em.persist(request);
		em.close();
		return request;
	}

	public void update(Contact request) {
		EntityManager em = EMF.get().createEntityManager();
		em.merge(request);
		em.close();

	}

	public void delete(Contact request) {
		EntityManager em = EMF.get().createEntityManager();
		em.remove(request);
		em.close();

	}

}
